# coding=utf-8
from datetime import datetime
import calendar


def get_date_str(date, _format='%Y-%m-%d %H:%M:%S'):
    return date.strftime(_format)


def get_date_detail(date):
    return date.year, date.month, date.day


def get_next_month_days(date):
    year = date.year
    month = date.month
    day = date.day
    month += 1
    if month > 12:
        year += 1
        month = 1
        day = 1
    days = calendar.monthrange(year, month)[1]
    return year, month, days


def get_next_year_month(date):
    year = date.year
    month = date.month
    month += 1
    if month > 12:
        year += 1
        month = 1
    return datetime(year=year, month=month, day=1)


def get_current_month_days(date=None):
    year = date.year
    month = date.month
    day = date.day
    days = calendar.monthrange(year, month)[1]
    return year, month, days


def get_date(year, month, day):
    return datetime(year, month, day)


def get_next_three_months_days(date=None, months=3):
    start_day = date.day
    step = 0
    # 获取当前月份最大天数
    year, month, day = get_current_month_days(date)
    step += day - start_day
    for i in range(0, months):
        # date = get_date(year, month, day)
        year, month, days = get_next_month_days(date)
        step += days
    return step


if __name__ == '__main__':
    no = datetime.now()
    # print(get_current_month_days(date=no))
    # print(get_date(2023, 1, 31))
    # days = get_next_three_months_days(no)
    # print(days)
    pass
